
<div class="container">
	<div class="container" style="padding:15px;">
		<form action="aaa" method="post" class="form-hrizontal">
			<div class="form-group">
				<label class="col-md-1 control-label" style="width:auto">选择班级：</label>
				<div class="col-md-2">
					<input class="form-control" id="banji" type="text" />
				</div>
			</div>
		</form>
	</div>
	<div id="table" class="container" style="flex-grow:1;display: none;"  >		
		<table id="mytable" class="datagrid">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-field="id">Id</th>
					<th data-field="stuNo">学号</th>
					<th data-field='name'>姓名</th>
				</tr>
			</thead>
		</table>
	</div>
</div>
	<script type="text/javascript">
	$(function(){
		$('#banji').combobox({
			url:'banji/list',
			valueField:'id',
			textField:'name',
			
			onchange:function(id){
/* 				$('#mytable').empty(); */
				var grid=$('#mytable');
				$('#table').show();
				grid.datagrid({
					path:'student',
					url:'page?classId='+id,
					editUrl:'edit?classId='+id,
					deleteUrl:'delete?classId='+id,
					saveUrl:'save?classId='+id,
					searchUrl:'search',
					search: false,
					buttons:[$.fn.datagrid.toolbar.buttons.add,$.fn.datagrid.toolbar.buttons.edit,$.fn.datagrid.toolbar.buttons.remove,$.fn.datagrid.toolbar.buttons.search,
						//显示图片
						$.createBtn({
						iconCls:'glyphicon glyphicon-picture',
						text:'查看照片',
						handler:function(){
							var self=$(this);
							var grid=$.fn.datagrid.toolbar.grid(self);
							var selections=grid.bootstrapTable('getSelections');
							if(selections.length!=1){
								bootbox.alert('请先选择一名学生');
								return;
							}
							var stuId=selections[0].id;
							var dialog=$('<div style="display:none;"/>');
							dialog.appendTo($('body'));
							var img=$('<img alt="无上传图片"/>');
							img.attr('src','student/download?id='+stuId);
							img.attr('width','100%');
							dialog.append(img);
							var dia=$.createDialog({
								title:''
							}).on('hidden.bs.modal',function(){
								dia.remove();
							});
							dia.find('div.modal-dialog').find('div.modal-content').find('div.modal-body').append(img);
							dia.modal('show');
						}
					}),
					//重置密码
					$.createBtn({
						icconCls:'glyphicon glyphicon-repeat',
						text:'重置密码',
						handler:function(){
							var self=$(this);
							var grid=$.fn.datagrid.toolbar.grid(self);
							var selections=grid.bootstrapTable('getSelections');
							if(selections.length!=1){
								bootbox.alert('请先选择一名学生');
								return;
							}
							var stuId=selections[0].id;
							$.post('student/resetPwd',{id:stuId},function(result){
								bootbox.alert('密码重置成功，初始密码为1111');
							})
						}
					}),
					]
					
				})	
			}
		});	
	});
	</script>
